package router

import (
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
	"minefieldplatform-go/app/api/cmdb"
	"minefieldplatform-go/app/api/task"
	"minefieldplatform-go/app/service/middleware"
)

func init() {

	s := g.Server()

	//cmdb routes
	s.Group("/", func(group *ghttp.RouterGroup) {
		group.Middleware(middleware.CORS)
		group.GET("/", cmdb.Overview)
		group.GET("/storagelist", cmdb.StorageList)
		group.POST("/storageupdate", cmdb.StorageUpdate)
		group.POST("/storagedel", cmdb.StorageDel)
		group.POST("/storageadd", cmdb.StorageAdd)
		group.POST("/storagedelall", cmdb.StorageDelAll)

		group.GET("/gpulist", cmdb.GpuList)
		group.POST("/gpuadd", cmdb.GpuAdd)
		group.POST("/gpudel", cmdb.GpuDel)
		group.POST("/gpuupdate", cmdb.GpuUpdate)
		group.POST("/gpudelall", cmdb.GpuDelAll)

		group.GET("/discover/storage", cmdb.StorageDiscover)
		group.GET("/discover/updatefile", cmdb.StorageUpdateFile)
		group.GET("/discover/gpu", cmdb.GpuDiscover)
	})

	//task routes
	s.Group("/task", func(group *ghttp.RouterGroup) {
		group.Middleware(middleware.CORS)
		group.GET("/machinelist", task.MachineList)
		group.POST("/storagetask", task.StorageTask)
		group.POST("/bashtask", task.BashTask)
		group.GET("/gpumonitorall", task.GpuMonitorAll)
		group.GET("/gpumonitor", task.GpuMonitor)
		group.GET("/storagemonitorall", task.StorageMonitorAll)
		group.GET("/storagemonitor", task.StorageMonitor)
	})

}
